package com.dkm.dkmproject.jssdk.controller;


import com.dkm.dkmproject.domain.Url;
import com.dkm.dkmproject.jssdk.utils.TokenSingleton;
import com.dkm.dkmproject.jssdk.utils.WechatUtil;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/wechat")
public class WechatController {

    @PostMapping("/config")
    public Map<String, String> config(@RequestBody Url url){
        Map<String, String> ret = new HashMap<>();
        TokenSingleton tokenSingleton = TokenSingleton.getInstance();
        Map<String, String> map = tokenSingleton.getMap();
        System.out.println("=======1111111111==="+url.getUrl());
        String jsapi_ticket = map.get("jsapi_ticket");
        // String newUrl = URLDecoder.decode(signUrl, "UTF-8");
        ret = WechatUtil.generateWxTicket(jsapi_ticket, url.getUrl());
        System.out.println(ret);
        return ret;
    }
}
